<!--
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 14:41:20
 * @LastEditTime: 2023-11-10 10:47:30
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description:   :gridOps="gridOptions" 
-->
<template>
  <el-container style="height: 100%">
    <el-main style="height: 100%">
      <sc-VxeTable ref="xGrid1" :gridEvts="gridEvents" :tablecode="'comprehensive_employee'" :gridOps="gridOps"
        :url="this.$API.comprehensive.employee.list">
      </sc-VxeTable>
    </el-main>
    <save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSuccess" @closed="dialog.save = false">
    </save-dialog>
  </el-container>
</template>
<script>
import skCategory from "@/components/skCategory";
import SaveDialog from "./save";
export default {
  components: {
    SaveDialog,
    skCategory,
  },
  name: "comprehensive_employee",
  data() {
    return {
      dialog: {
        save: false,
      },

      gridEvents: {
        cellDblclick: ({ row }) => {
          this.edit(row);
        },
        add: ({ code }) => {
          this.openSave(code);
        },
        edit: () => {
          this.edit();
        },
      },
      gridOps: { rowConfig: { height: 100, useKey: "id" } },
    };
  },
  methods: {
    openSave: function () {
      this.dialog.save = true;
      this.$nextTick(() => {
        this.$refs.saveDialog.open();
      });
    },
    categoryselect: function (data, ids) {
      this.$refs.xGrid1.search("department_id", ids, "in");
      this.handleSuccess();
    },
    handleSuccess() {
      this.$refs.xGrid1.refresh();
    },
    edit(item) {
      let selected = {};
      if (typeof item == "undefined") {
        let selects = this.$refs.xGrid1.xGrid.getCheckboxRecords();
        if (selects.length == 0) {
          this.$message.error("必须选中元素");
          return;
        } else {
          selected = selects[0];
        }
      } else selected = item;
      this.dialog.save = true;
      this.$nextTick(() => {
        this.$refs.saveDialog.open("edit").setData(selected);
      });
    },
  },
};
</script>
